/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package slicktemplate;

import java.awt.FontMetrics;
import java.io.Serializable;
import java.util.ArrayList;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.state.StateBasedGame;

/**
 *
 * @author Josh
 */
public class Wall extends Collideable implements Renderable, Attackable, Updateable,Serializable {

    float x, y;
    final int DRAG_STATE = 1;
    final int WALL_STATE = 2;
    final int MAX_HEALTH = 300;
    int state = DRAG_STATE;
    public static final ArrayList<Wall> all = new ArrayList<Wall>();
    SerializableImage sprite;
    private float health = 300;

    public Wall(float x, float y) {
        all.add(this);
        this.x = x;
        this.y = y;
        try {
            sprite = new SerializableImage("sprites/wall.png"); //try to load the sprite
        } catch (Exception e) {
            e.printStackTrace();
        }
        boundingBox = new Rectangle(x, y, sprite.getWidth() - 1, sprite.getHeight() - 1);
    }

    @Override
    public void render(Graphics g) {
        sprite.draw(x, y);
        g.setColor(Color.red);
        g.fillRect(x, y, sprite.getWidth(), 6);
        g.setColor(Color.green);
        g.fillRect(x, y, sprite.getWidth()*health/MAX_HEALTH, 6);
    }

    @Override
    public float getX() {
        return x;
    }

    @Override
    public float getY() {
        return y;
    }

    @Override
    public float getHealth() {
        return health;
    }

    public void subHealth(int sub) {
        health -= sub;
    }

    public boolean update(Input input, StateBasedGame sb) {
        return health <= 0 ? true : false;
    }
     public void mousePressed(StateBasedGame sb, int button) {

    }

    @Override
    boolean isBuilding() {
        return true;
    }
}
